<template>
  <div>
    <ul class="ul">
      <li
        v-for="(item, index) in store.Aid === 0
          ? store.List
          : store.Aid === 1
          ? store.Active
          : store.Aid === 2
          ? store.Comple
          : store.Aid === 3
          ? store.List
          : ''"
        :key="index"
        :class="item.flag == true ? 'active li' : 'li'"
      >
        <span class="ck" @click="chage(index)" v-if="item.flag === true">
          √
        </span>
        <input type="checkbox" class="ck" @click="chage(index)" v-else />
        <p>{{ item.name }}</p>
        <span @click="del(index)">x</span>
      </li>
    </ul>
  </div>
</template>

<script setup>
import { useStore } from "../stores/counter";
const store = useStore();
const chage = (index) => {
  store.Ids = index;
  console.log(store);
  store.Change();
};
const del = (index) => {
  store.id = index;
  store.Del();
};
defineProps({
  msg: {
    type: String,
    required: true,
  },
});
</script>

<style>
* {
  padding: 0;
  margin: 0;
}

li {
  list-style: none;
}

.ck {
  margin-right: 10px;
}

.ul {
  width: 300px;
  margin: 0px auto;
  margin-bottom: 120px;
}

.li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  box-sizing: border-box;
  padding: 2px 4px;
  font-weight: bold;
  border-radius: 5px;
}

.active {
  color: #fff;
  background-color: #fe7345;
  text-decoration: line-through;
  animation-name: flip-horizontal;
  animation-duration: 1s;
  animation-timing-function: ease;
  animation-delay: 0s;
  animation-iteration-count: 1;
  animation-direction: normal;
  animation-fill-mode: none;
  text-decoration: line-through;
  animation: flip-horizontal 1s ease 0s 1 normal none;
}

@keyframes flip-horizontal {
  0% {
    transform: rotateX(0);
  }
  100% {
    transform: rotateX(-360deg);
  }
}

.li p {
  flex: 1;
}
</style>
